package com.app.utils.base.j2se;

import java.text.DecimalFormat;

/**
 * Description
 * Created by 王伟
 * Date create on 10:38 2018/6/14.
 */
public class DecimalUtils {

    public static String format(double d, int num){
        StringBuffer sb = new StringBuffer("######0");
        if(num>0){
            sb.append(".");
            for(int i=0;i<num;i++){
                sb.append("0");
            }
        }
        DecimalFormat df = new DecimalFormat(sb.toString());
        return df.format(d);
    }
}
